import React, { Component } from 'react';
import { Text, Image, View, TextInput, TouchableOpacity } from 'react-native';
import { unitWidth } from '../constants/AdapterUtil';
import { MyHeader } from '../components/MyHeader';
import Colors from '../constants/Colors';
import { postFetch } from '../constants/HttpExtension';
import { show } from '../constants/Toast';
import { api_member_info_updateUserInfo } from '../constants/HttpServices';
import { SubmitButton1 } from '../components/Button';
import { MyInput1 } from '../components/Input';
import TextUtil from '../constants/TextUtil';
import { MerchantCertificationItem } from '../components/Item';
import CommonUtil from '../constants/CommonUtil';

export default class MerchantCertificationScreen extends Component {

    constructor(props) {
        super(props)

        const { navigation } = this.props;
        this.state = {

        }
    }

    componentDidMount() {
        this.props.navigation.addListener('didFocus', payload => {
            CommonUtil.getUserInfo();
            CommonUtil.getCompanyInfo();
        })
    }

    componentWillUnmount() {

    };

    render() {
        return (
            <View style={{ flex: 1, backgroundColor: Colors.colorEF }}>
                <MyHeader title='认证' leftImg={require('../res/ic_arrow_left.png')} leftClick={() => { this.props.navigation.pop() }} />
                <MerchantCertificationItem
                    icon={
                        <Image source={require('../res/me_smrz.png')} style={{ width: 28 * unitWidth, height: 28 * unitWidth, marginLeft: 15 * unitWidth }} resizeMode='stretch' />
                    } text1='实名认证' text2='(认证通过后可进行线上支付、线下交易)' text3='去认证' isLast={false}
                    onPress={() => {
                        if (global.userInfo.is_company_realname == '0') {
                            this.props.navigation.navigate('EnterpriseRealNameCertification')
                        } else {
                            // show('已认证');
                            this.props.navigation.navigate('EnterpriseRealNameCertification')
                        }
                    }} />
                <MerchantCertificationItem
                    icon={
                        <Image source={require('../res/me_qyrz.png')} style={{ width: 27 * unitWidth, height: 26 * unitWidth, marginLeft: 15 * unitWidth }} resizeMode='stretch' />
                    } text1='企业认证' text2='(认证通过后可进行报价、线下交易)' text3='去认证' isLast={false}
                    onPress={() => {
                        if (global.userInfo.is_company_realname == '1') {
                            this.props.navigation.navigate('EnterpriseCertification')
                        } else if (global.userInfo.is_company_realname == '0') {
                            show('请先进行实名认证');
                        } else {
                            // show('已认证');
                            this.props.navigation.navigate('EnterpriseCertification')
                        }
                    }}
                />
                <MerchantCertificationItem
                    icon={
                        <Image source={require('../res/me_sdrz.png')} style={{ width: 26 * unitWidth, height: 26 * unitWidth, marginLeft: 15 * unitWidth }} resizeMode='stretch' />
                    } text1='实地认证' text2='(认证通过后可进行线上交易)' text3='去认证' isLast={true}
                    onPress={() => {
                        if (global.userInfo.is_company_realname == '2') {
                            this.props.navigation.navigate('EnterpriseIndeedCertification')
                        } else if (global.userInfo.is_company_realname == '3') {
                            show('已认证');
                        } else {
                            show('请先进行企业认证');
                        }
                    }} />
            </View>
        );
    }
}